package com.leetcode.partition6;

import java.util.HashSet;
import java.util.Set;

/**
 * @author `RKC`
 * @date 2021/11/1 8:06
 */
public class LC575分糖果 {

    public static int distributeCandies(int[] candyType) {
        return greedy(candyType);
    }

    public static void main(String[] args) {
//        int[] candyType = {1, 1, 2, 2, 3, 3};
        int[] candyType = {1, 1, 2, 3, 3};
//        int[] candyType = {6, 6, 6, 6};
        System.out.println(distributeCandies(candyType));
    }

    private static int greedy(int[] candyType) {
        Set<Integer> candySet = new HashSet<>();
        int limited = candyType.length >> 1;
        for (int candy : candyType) {
            candySet.add(candy);
        }
        return Math.min(candySet.size(), limited);
    }
}
